package LuoGu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
public class P1102 {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int arrLen=(int)st.nval;
        int[] a=new int[arrLen];
        st.nextToken();
        int c=(int)st.nval;
        int sum=0;
        for (int i = 0; i < arrLen; i++) {
            st.nextToken();
            a[i]=(int)st.nval;
        }
        Arrays.sort(a);
        for (int i = 0; i < arrLen; i++) {
            int tmp=a[i]+c;
            int index=0;
            int left=0;
            int right=arrLen-1;
            while(left< right){
                int mid=(left+right)>>1;
                if(a[mid]<tmp){
                    left=mid+1;
                }else if(a[mid]>=tmp){
                    right=mid;
                }
            }
            if(a[left]==tmp){
                index=left;
            }else{
                index=-1;
            }
            if(index!=-1){
                while(index<arrLen&&a[index++]==tmp){
                    sum++;
                }
            }
        }
        System.out.print(sum);
    }
}
